package com.oa.ch.dao;

import java.util.List;

import org.hibernate.criterion.Example;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oa.domain.Attendance;
import com.oa.domain.Dept;
import com.oa.domain.Emp;

public class AttDaoImpl extends HibernateDaoSupport implements AttDao{

	public List<Attendance> getAttByExample(Attendance attendance) {
		return getSession().createCriteria(Attendance.class).add(Example.create(attendance)).list();
		/*return getSession().createQuery("from Attendance where empno="+attendance.getEmpno()).list();*/
	}

	public List<Emp> getEmpsByExample(Emp emp) {
		// TODO Auto-generated method stub
		return getSession().createCriteria(Emp.class).add(Example.create(emp)).list();
	}

	public Emp getEmpById(Long empno) {
		// TODO Auto-generated method stub
		System.out.println("empno:"+empno);
		return (Emp) getSession().createQuery("from Emp where empno="+empno).list().get(0);
		 
	}

	public List<Dept> getDeptsByExample(Dept dept) {
		// TODO Auto-generated method stub
		return getSession().createCriteria(Dept.class).add(Example.create(dept)).list();
	}

}
